home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue46 / packages / DinoSource.Zip / HiddenMenus.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-05-11  |  2.2 KB  |  98 lines

  1. unit HiddenMenus;
  2.  
  3. {$ifdef Ver100} { Delphi 3.0x }
  4.   {$define DelphiLessThan4}
  5. {$endif}
  6. {$ifdef Ver110} { C++ Builder 3.0x }
  7.   {$define DelphiLessThan4}
  8. {$endif}
  9.  
  10. {$ifndef DelphiLessThan4}
  11.   'Only for Delphi 3'
  12. {$endif}
  13. interface
  14.  
  15. procedure Register;
  16.  
  17. implementation
  18.  
  19. uses
  20.   Forms, CommonStuff, Menus, SysUtils, Dialogs;
  21.  
  22. type
  23.   THiddenMenus = class(TObject)
  24.   private
  25.     FCompError,
  26.     FViewAsText,
  27.     FUsingHelp,
  28.     FAPI: TMenuItem;
  29.   public
  30.     constructor Create;
  31.     destructor Destroy; override;
  32.     procedure Setup;
  33.     procedure TidyUp;
  34.   end;
  35.  
  36. const
  37.   //Hidden menu item components
  38.   SCompError = 'SearchCompErrItem';
  39.   SViewAsText = 'ViewSwapSourceFormItem';
  40.   SUsingHelp = 'HelpUsingHelpItem';
  41.   SAPI = 'HelpAPIItem';
  42.  
  43. constructor THiddenMenus.Create;
  44. begin
  45.   inherited Create;
  46. end;
  47.  
  48. destructor THiddenMenus.Destroy;
  49. begin
  50.   TidyUp;
  51.   inherited Destroy
  52. end;
  53.  
  54. procedure THiddenMenus.Setup;
  55. begin
  56.   //This section just displays some normally hidden menu items
  57.   FCompError := GetComponent(Application.MainForm, SCompError, SGenericError + SCompError)
  58.     as TMenuItem; //Search | Show Last Compile Error
  59.   FViewAsText := GetComponent(Application.MainForm, SViewAsText, SGenericError + SViewAsText)
  60.     as TMenuItem; //View | View as Text
  61.   FUsingHelp := GetComponent(Application.MainForm, SUsingHelp, SGenericError + SUsingHelp)
  62.     as TMenuItem; //Help | How to Use Help
  63.   FAPI := GetComponent(Application.MainForm, SAPI, SGenericError + SAPI)
  64.     as TMenuItem; //Help | Windows API
  65.   FCompError.Visible := True;
  66.   FViewAsText.Visible := True;
  67.   FUsingHelp.Visible := True;
  68.   FAPI.Visible := True;
  69. end;
  70.  
  71. procedure THiddenMenus.TidyUp;
  72. begin
  73.   //Put menus back to default hidden state
  74.   FCompError.Visible := False;
  75.   FViewAsText.Visible := False;
  76.   FUsingHelp.Visible := False;
  77.   FAPI.Visible := False;
  78. end;
  79.  
  80. var
  81.   HiddenMenusObject: THiddenMenus;
  82.  
  83. procedure Register;
  84. begin
  85.   HiddenMenusObject.Setup
  86. end;
  87.  
  88. initialization
  89.   try
  90.     HiddenMenusObject := THiddenMenus.Create
  91.   except
  92.     on E: Exception do
  93.       ShowMessage(SSetupError + ': ' + E.Message)
  94.   end;
  95. finalization
  96.   HiddenMenusObject.Free
  97. end.
  98.